home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / vector / bitvecmac.m4 < prev    next >
Text File  |  1990-05-16  |  3KB  |  130 lines

  1. /* bitvecmac.m4 -- m4 macro templates for BitVecs
  2.  
  3.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  4.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  5.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  6.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  7.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  8.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  9.  
  10. Author:
  11.     K. E. Gorlen
  12.     Bg. 12A, Rm. 2017
  13.     Computer Systems Laboratory
  14.     Division of Computer Research and Technology
  15.     National Institutes of Health
  16.     Bethesda, Maryland 20892
  17.     Phone: (301) 496-5363
  18.     uucp: uunet!nih-csl!keith
  19.     Internet: keith@alw.nih.gov
  20.  
  21. Function:
  22.     
  23. Modification History:
  24.  
  25. $Log:    bitvecmac.m4,v $
  26. Revision 3.0  90/05/16  23:00:47  kgorlen
  27. Release for 1st edition.
  28.  
  29. Revision 2.206  90/05/13  22:06:59  kgorlen
  30. Pre-release.
  31.  
  32. Revision 2.204  89/10/08  09:43:16  keith
  33. Pre-release
  34.  
  35. Revision 2.203  89/08/14  13:13:48  ted
  36. Pre-release
  37.  
  38. Revision 2.202.1.1  89/08/04  13:35:06  ted
  39. Removed register declarations
  40.  
  41. Revision 2.203  89/08/04  10:36:43  ted
  42. Removed all register declarations for integers.
  43.  
  44. Revision 2.202  89/06/28  23:34:01  keith
  45. Base revision for AT&T C++ R2.0 release (Cycle 20)
  46.  
  47. Revision 2.201.1.2  89/06/28  22:47:28  keith
  48. Change name of 1st argument to BITVECGEN.
  49.  
  50. Revision 2.201.1.1  89/06/19  21:51:02  keith
  51. Base revision for R2.0 Cycle 18.
  52.  
  53. Revision 2.201  89/05/12  13:46:52  keith
  54. Release for R2.0 Beta test.
  55.  
  56. Revision 2.200  89/05/03  23:36:19  keith
  57. Utilize abstract classes.
  58.  
  59. Revision 2.122  89/05/03  23:33:29  keith
  60.  
  61.  
  62. Revision 2.121  89/04/25  13:33:52  keith
  63. Base revision for C++ R1.2.1 compatible version.
  64.  
  65. Revision 2.0  88/03/29  21:56:45  keith
  66. Version 2 Release 2
  67.  
  68. Revision 1.1  88/01/17  09:47:26  keith
  69. Initial revision
  70.  
  71.     
  72. */
  73.  
  74. // BITVECGEN(BitVecPt,Length,Condition,Advance)
  75. define(BITVECGEN,
  76. {
  77.     bitVecByte m;
  78.     bitVecByte* bp = $1;
  79.     unsigned i = ($2) >> 3;
  80.     while (i--) {
  81.         m = 0;
  82.         if ($3) m |= 0x01;  $4;
  83.         if ($3) m |= 0x02;  $4;
  84.         if ($3) m |= 0x04;  $4;
  85.         if ($3) m |= 0x08;  $4;
  86.         if ($3) m |= 0x10;  $4;
  87.         if ($3) m |= 0x20;  $4;
  88.         if ($3) m |= 0x40;  $4;
  89.         if ($3) m |= 0x80;  $4;
  90.         *bp++ = m;         
  91.     }                 
  92.     if ((i = ($2)&7) != 0) {
  93.         m = 0;
  94.         int mm = 1;
  95.         while (i--) {
  96.             if ($3) m |= mm;
  97.             mm <<= 1;
  98.             $4;
  99.         }
  100.         *bp = m;
  101.     };
  102. }
  103. )
  104.  
  105. // BITVECSCAN(BitVec,Length,Statement)
  106. define(BITVECSCAN,
  107. {
  108.     bitVecByte m;
  109.     const bitVecByte* bp = ($1).pt();
  110.     unsigned i = ($2) >> 3;
  111.     while(i--) {
  112.         m = *bp++;
  113.         if (m&0x01) $3;
  114.         if (m&0x02) $3;
  115.         if (m&0x04) $3;
  116.         if (m&0x08) $3;
  117.         if (m&0x10) $3;
  118.         if (m&0x20) $3;
  119.         if (m&0x40) $3;
  120.         if (m&0x80) $3;
  121.     }    
  122.     m = *bp;
  123.     i = ($2) & 7;
  124.     while (i--) {
  125.         if (m&0x01) $3;
  126.         m >>= 1;
  127.     }
  128. }
  129. )
  130.